
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int maxArea(int[] height) {
        //双指针指向头尾
        int start = 0;
        int end = height.length-1;
        int vertical = 0;   //底
        int bottomLen = 0;  //高
        int maxArea = 0;    //最大面积

        while (start != end){
            bottomLen = end - start;
            vertical = min(height[start],height[end]);
            if (bottomLen * vertical > maxArea){
                maxArea = bottomLen * vertical; //如果底*高比最大面积大，则将最大面积赋值给 底*高
            }

            if (vertical == height[start]) {    //双指针哪个对应的值更小，谁更小谁就缩进
                start++;
            } else {
                end--;
            }
        }


        return maxArea;
    }

    private int min(int num1, int num2){
        return (num1 < num2) ? num1 : num2;
    }
}
//leetcode submit region end(Prohibit modification and deletion)
